<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>凉山州2018年中考志愿填报</title>
<link rel="stylesheet" href="css/newStyle.css"
	th:href="@{/css/newStyle.css}">
</head>
<body>
	<div class="mainBox">
		<div class="mainBox_inner">
			<h1>凉山州2018年中考志愿填报系统(毕业初中)</h1>
			<div class="formOutBox">
				<h2 th:utext="'【' + ${junior.byzxmc} + '】你正在修改密码'">修改密码</h2>
				<form action="/junior/doChangePasswd" th:action="@{/junior/doChangePasswd}"
					th:object="${changePassword}" method="post" id="updatapassword"
					class="formbox">
					<div class="form_item">
						<label for="oldpassword">原&emsp;密&emsp;码：</label> <input
							type="password" th:value="${oldPassword}" maxlength="8"
							name="oldPassword" id="oldPassword" placeholder="请输入原密码" required>
					</div>
					<div class="form_item">
						<label for="newpassword">新&emsp;密&emsp;码：</label> <input
							type="password" th:value="${newPasswordOne}" maxlength="8"
							name="newPasswordOne" id="newPasswordOne" placeholder="请输入新密码"
							required>
					</div>
					<div class="form_item">
						<label for="newpasswordAgin">确认新密码：</label> <input type="password"
							maxlength="8" th:value="${newPasswordTwo}" name="newPasswordTwo"
							id="newPasswordTwo" placeholder="请再输入新密码" required>
					</div>
					<div class="form_item btnbox">
						<button type="button" id="updatepassword" class="btnclass">提交</button>
					</div>
					<div class="form_item ">
						<label class="bmhpassworderror" th:text="${msg}" ></label>
					</div>
				</form>
				<div class="tipsBox">
					<ul>
					</ul>
				</div>
			</div>
		</div>
	</div>
</body>
<script src="js/jquery-1.12.3.js"></script>
<script src="js/gVerify.js"></script>
<script src="js/commen.js"></script>
<script src="js/checkPassword.js"></script>
<script>
$("#oldPassword").click(function(){

	$(".bmhpassworderror").html("")
})	
	//点击提交按钮
	/*
	 密码验证部分:
		 1.密码必须包含数字和字符
		 2.密码长度最低为8
	 * */
	//点击提交按钮
	$("#updatepassword").on(
			'click',
			function() {
				var newpassword = $("#newPasswordOne").val();
				//检查是否没有输入密码
				if (newpassword == "" || $("#newPasswordOne").val() == ""
						|| $("#oldPassword").val() == "") {
					alert("请输入密码！");
				} else {
					//检查新密码两次输入是否一致
					if (newpassword == $("#newPasswordTwo").val()) {
						/*你的数据判断,主要判断该用户的老密码输入是否正确*/
						if (check_str(newpassword) == true) {
							//判断完后提交代码
							$("#updatapassword").submit();//这个是直接提交form表单的方式
							/*以下是ajax请求的时候需要使用，如果不实用ajax请求，则忽略*/
							/*
							var data = new Object();
							//data.act = "changePassword";
							//data.bmh = $("#bmh").val();
							data.oldPassword = $("#oldpassword").val();
							data.newPasswordOne = $("#newPasswordOne").val();
							data.newPasswordTwo = $("#newPasswordTwo").val();
							var data_str = JSON.stringify(data);
							 //传给后台数据的格式：
							 //{"act":"changePassword","bmh":"11111","oldpassword":"b111111111","newpassword":"a11111111",
							 //"newpasswordAgin":"a11111111"}	
							$.ajax({
								type:"POST",
								url:"changePasswd",
								data: data_str,
							    dataType: "json",
							    success:function (data) {//直接在后台判断输入的老密码是否正确
							        console.log(data);
							        if (data == true) {
							        	alert("修改成功！");
							        }else {
							        	alert("对不起"+data);
							        }
								}
							});
							*/
							/*以下是ajax请求的时候需要使用，如果不实用ajax请求，则忽略*/
						} else {
							alert(check_str(newpassword));
						}
					} else {
						alert("两次输入的密码不同，请重新输入！");
					}
				}

			})
</script>
</html>